package com.roc.dao;

import java.util.List;
import java.util.Map;

import com.roc.bean.TermBean;
import com.roc.pojo.Estidinfo;
import com.roc.pojo.Operators;
import com.roc.pojo.TPosInfo;
import com.roc.pojo.TPosReplace;
import com.roc.pojo.TblDictionaryItem;
import com.roc.pojo.TblDictionaryLayerItem;
import com.roc.pojo.TblTermInf;
import com.roc.pojo.TermInfo;
import com.roc.pojo.TermInfoTmp;
import com.roc.pojo.Termapply;
import com.roc.pojo.YjPosAgent;
import com.roc.pojo.YjPosInfo;
import com.roc.pojo.YjSnInfo;

/**
 * 
 * @author 陈锴
 * 
 * 2014-08-13
 * 
 * 终端管理
 *
 */

public interface ITerminalDao extends IBaseDao{
	
	Termapply queryTermapplyId(long id) throws DaoException;
	
	//获取最大终端号
	int queryMaxTermapply() throws DaoException;
	
	
	void editTermTid(int tid) throws DaoException;
	
	YjPosInfo queryYjPosInfo(String serialNum,String posBrand) throws DaoException;
	
	TPosInfo queryYsbYjPosInfo(String serialNum,String posBrand) throws DaoException;
	
	TermInfo querTermInfo(String tid) throws DaoException; 
	//根据商户号查询终端
	List<TermBean> queryTerByMid(String mid)throws DaoException;
	Estidinfo queryEstidinfo(String tid) throws DaoException;
	
	public List<Object> getTermapplyList(String isused,String seriaNum,Long agentid,String posBrand,String posType,String posName);
	/**
	 * 查询yj_pos_info表记录
	 * @param seriaNum
	 * @param posBrand
	 * @param posType
	 * @param posName
	 * @return
	 */
	public long getPosInfo(String seriaNum,String posBrand,String posType,String posName);
	
	public YjPosAgent getYjPosAgent(String serialNum,Long agentId) throws DaoException;
	
	public List getOpertorsIdsTreeById(Long id) throws DaoException;
	
	public void deletePosAgentByAgentIdsAndSN(String sn,List<Long> list) throws DaoException;

    public void updatePosAgentByAgentAndSN(String sn,Long agentId) throws DaoException;
    
    public List getPosInfosForBatchRecall(String seriaNum,String orgCode,Long agentId,String posBrand,String posType,String posName,String isUsed) throws DaoException;
    
    public void deletePosAgentByAgentIdAndSn(Long agentId,String sn) throws DaoException;
    
    public void deletePosInfo(String sn,String posBrand,String posType,String posName) throws DaoException;
    List<TermBean> queryTerChangeByMid(String mid)throws DaoException;
    public  List<TermInfoTmp> queryTermInfoTmpByMid(String mid)throws DaoException;
    public List<TermInfoTmp> queryTermTmpNULLByMid(String mid)throws DaoException;
    
   // public TermInfoTmp queryTermInfoTmpByMid(String mid)throws DaoException;
    

	/**
	 * 查询型号
	 * @param tid
	 * @throws DaoException
	 */
	public List<TblDictionaryLayerItem> queryModelItemByType(TblDictionaryLayerItem item) throws DaoException;
	

	/**
	 * 查询基础信息(如品牌,类型)
	 * @param tid
	 * @throws DaoException
	 */
	public List<TblDictionaryItem> queryDictionaryItemByType(TblDictionaryItem item , String symbol) throws DaoException;
	
	/**
	 * 分配终端SN
	 * @param tblTermInf
	 */
	public void setSerialNumber(String termID,String merchtNo,YjPosInfo yjPos,String orgCode)throws DaoException;
	/**
	 * 修改SN状态yj_pos_agent
	 * @param serialNum\agentid
	 * @throws DaoException
	 */
	public void updateSerialNumberStatus(String serialNum,String posBrandCode,long agentid,String accountNo,String tid)throws DaoException;
	
	/**
	 * 修改SN状态2  yj_pos_info
	 * @param serialNum
	 * @throws DaoException
	 */
	public void updateSerialNumberStatus2(String serialNum,String posBrandCode,String mid,String tid)throws DaoException;
	/**
	 * 查询终端信息
	 * @param mid
	 * @return
	 * @throws DaoException
	 */
	TblTermInf queryTermInfo(String tid,String mid) throws DaoException;

	/**
	 * 删除sn序列号
	 * @param sn
	 * @param op
	 * @return
	 * @throws DaoException
	 */
	void delTermSNInfo(String sn,String posBandCode,Operators op) throws DaoException;
	/**
	 * 删除sn序列号关联信息
	 * @param sn
	 * @param op
	 * @return
	 * @throws DaoException
	 */
	void delTermSNAgentInfo(String sn,String posBandCode,Operators op) throws DaoException;
	
	/**
	 * 撤回sn序列号关联信息
	 * @param sn
	 * @param op
	 * @return
	 * @throws DaoException
	 */
	int revTermSNAgentInfo(String sn,String posBandCode,Operators op) throws DaoException;
	
	/**
	 * 修改sn关联信息 使用状态 
	 * @param sn
	 * @param posBandCode
	 * @param op
	 * @throws DaoException
	 */
	public void updTermSNAgentUsedStatus(String sn,String posBandCode, Operators op) throws DaoException;
	/**
	 * 获取初始序列号
	 * @param mid
	 * @param tid
	 * @param serialNum
	 * @return
	 * @throws DaoException
	 */
	public YjSnInfo getOriginSerialNum(String mid,String tid)throws DaoException;
	/**
	 *  解绑终端并修改参数
	 * @param serialNum_origin
	 * @param serialNum_new
	 * @param mid
	 * @param tid
	 * @throws DaoException
	 */
	public int unbindTerminal(String serialNum_origin,String serialNum_new,String mid,String tid,String posBrandCode,String oldPosBrandCode)throws DaoException;
	public int unbindAgentPos(String serialNum,String agentID,String accountNo,String termCode,String posBrandCode)throws DaoException;
	public int unbindInfoPos(String serialNum,String posBrandCode)throws DaoException;
	public String agentIDbySerialNum(String serialNum,String posBrandCode)throws DaoException;

	long getTPosInfo(String seriaNum, String posBrand, String posType, String posName);

	List<Object> getYsbTermapplyList(String isused, String seriaNum, Long agentid, String posBrand, String posType,
			String posName,String roleType);
	
	
	/**
	 * 查询终端交易信息
	 * @param mid
	 * @return
	 * @throws DaoException
	 */
	Map<String, String> findYsbTransPos(TPosInfo tPosInfo) throws DaoException;

	int selectYsbTransInfo(TPosInfo tPosInfo) throws DaoException;
	
	int selectYsbFifteenTransInfo(TPosInfo tPosInfo) throws DaoException;
	
	int selectYsbHistoryTransInfo(TPosInfo tPosInfo) throws DaoException;
	
	String selectYsbMaxAgent(TPosInfo tPosInfo) throws DaoException;
	
	void updateYsbPosAgent(TPosInfo tPosInfo) throws DaoException;
	
	void unboundYsbPosInfo(TPosInfo tPosInfo) throws DaoException;
	
	void dealWMRecord(TPosInfo tPosInfo) throws DaoException;
	
	String queryExistSn(TPosInfo tPosInfo) throws DaoException;
	
	int serialNumGenerator(TPosInfo tPosInfo) throws DaoException;
	
	void insertSnInfo(YjSnInfo snInfo) throws DaoException;
	
	void unboundTerminal(TPosInfo tPosInfo) throws DaoException;
	
	int selectYsbD0FeeInfo(TPosInfo tPosInfo) throws DaoException;
	void dealYsbD0FeeInfo(TPosInfo tPosInfo) throws DaoException;
	
	int selectYsbD0ProductInfo(TPosInfo tPosInfo) throws DaoException;
	void dealYsbD0ProductInfo(TPosInfo tPosInfo) throws DaoException;
	
	int selectYsbHxD0ProductInfo(TPosInfo tPosInfo) throws DaoException;
	void dealYsbHxD0ProductInfo(TPosInfo tPosInfo) throws DaoException;

	
	/**
	 * SN是否可撤回
	 * @param serialNum sn
	 * @param posBrand 品牌
	 * @param loginOper 当前登录账号
	 * @return 
	 * @throws DaoException
	 */
	String queryRevSnByAgentId(String serialNum,String posBrand,Operators loginOper) throws DaoException ;
	/**
	 * 撤回云商宝sn序列号关联信息
	 * @param sn
	 * @param op
	 * @return
	 * @throws DaoException
	 */
	void revYsbTermSNAgentInfo(String sn,String posBandCode,String asset_flag,Operators op) throws DaoException;
	
	/**
	 * 修改云商宝sn关联信息 使用状态 
	 * @param sn
	 * @param posBandCode
	 * @param op
	 * @throws DaoException
	 */
	 void updYsbTermSNAgentUsedStatus(String sn,String posBandCode, Operators op) throws DaoException;
	
	/**
	 * 删除当天T1历史费率
	 * @param tPosInfo
	 * @throws DaoException
	 */
	void dealYsbT1HisFeeInfo(TPosInfo tPosInfo) throws DaoException ;
	
	/**
	 * 通过商户号和卡类别 更新T1费率
	 * @param mchtFeePercent
	 * @param mchtFeePctMax
	 * @param mchtCd
	 * @param subBizCd
	 * @throws DaoException
	 */
	void updYsbT1FeeByFeeCd( String mchtFeePercent,String mchtFeePctMax, String mchtCd , String subBizCd ) throws DaoException;

	
	void boundYsbPosAgent(TPosInfo tPosInfo) throws DaoException;
	
	void boundYsbPosInfo(TPosInfo tPosInfo) throws DaoException;
	
	/**
	 * 添加云商宝换机记录
	 * @param posReplace
	 * @throws DaoException
	 */
	void insertTPosReplace(TPosReplace posReplace) throws DaoException ;
	/**
	 * 修改原始序列号信息
	 * @param tPosInfo
	 * @throws DaoException
	 */
	void updateSnInfo(YjSnInfo yjSnInfo) throws DaoException ;
	
	/**
	 * 换机修改终端信息
	 * @param tPosInfo
	 * @throws DaoException
	 */
	void replaceTerminal(TPosInfo tPosInfo) throws DaoException ;
	/**
	 * 通过商户号和终端号查询直属代理商id
	 * @param tPosInfo
	 * @return
	 * @throws DaoException
	 */
	String selectYsbDirAgentByTerm(TPosInfo tPosInfo) throws DaoException ;
	
	/**
	 * 通过SN和代理商id查询云商宝sn绑定信息
	 * @param tPosInfo
	 * @return
	 * @throws DaoException
	 */
	TPosInfo selectYsbSnInfoByAgent(TPosInfo tPosInfo) throws DaoException ;
	
	/**
	 * 通过代理商id查询 所有的上级账号信息
	 * @param op
	 * @return
	 * @throws DaoException
	 */
	Map<String, String> selectAllSuperInfoByAgentId(Operators op) throws DaoException ;
}
